<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : matches.xsl
    Created on : Utorok, 2010, apríl 20, 12:23
    Author     : Football-Statistics Team
    Description: single match transformation, parameters are localized messages sent from JSP
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" omit-xml-declaration="yes" media-type="html/text"/>
    <xsl:param name="url"/>
    <xsl:param name="league"/>
    <xsl:param name="season"/>
    <xsl:param name="date"/>
    <xsl:param name="time"/>
    <xsl:param name="round"/>
    <xsl:param name="goals"/>
    <xsl:param name="cards"/>
    <xsl:param name="changes"/>
    <xsl:param name="players"/>
    <xsl:param name="stadium"/>
    <xsl:param name="referee"/>
    <xsl:param name="spectators"/>
    <xsl:param name="home"/>
    <xsl:param name="guests"/>
    <xsl:param name="score"/>
    <xsl:template match="/match">
        <table class="tmatches">
            <thead>
                <tr>
                    <th><xsl:value-of select="$league"/></th>
                    <th><xsl:value-of select="$season"/></th>
                    <th><xsl:value-of select="$round"/></th>
                    <th><xsl:value-of select="$date"/></th>
                    <th><xsl:value-of select="$time"/></th>
                    <th><xsl:value-of select="$referee"/></th>
                    <th><xsl:value-of select="$stadium"/></th>
                    <th><xsl:value-of select="$spectators"/></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td><xsl:value-of select="league"/></td>
                    <td><xsl:value-of select="season"/></td>
                    <td><xsl:value-of select="round"/></td>
                    <td><xsl:value-of select="date"/></td>
                    <td><xsl:value-of select="time"/></td>
                    <td><xsl:value-of select="referee"/></td>
                    <td><xsl:value-of select="stadium"/></td>
                    <td><xsl:value-of select="spectators"/></td>
                </tr>
            </tbody>
        </table>
        <table class="teams">
            <tr>
                <td class="l head"><xsl:value-of select="$home"/></td>
                <td>&#160;</td>
                <td class="r head"><xsl:value-of select="$guests"/></td>
            </tr>
            <tr>
                <th class="l"><xsl:value-of select="home"/></th>
                <th style="background:transparent;border:none;">&#160;</th>
                <th class="r"><xsl:value-of select="guests"/></th>
            </tr>
            <tr>
                <td class="l h2"><xsl:value-of select="$score"/></td>
                <td>&#160;</td>
                <td class="r h2"><xsl:value-of select="$score"/></td>
            </tr>            
            <tr>
                <td class="l">
                    <strong><xsl:value-of select="score/full/@home"/></strong>&#160;(<xsl:value-of select="score/half/@home"/>)
                </td>
                <td>&#160;</td>
                <td class="r">
                    <strong><xsl:value-of select="score/full/@guests"/></strong>&#160;(<xsl:value-of select="score/half/@guests"/>)
                </td>
            </tr>
            <tr>
                <td class="l h2"><xsl:value-of select="$goals"/></td>
                <td>&#160;</td>
                <td class="r h2"><xsl:value-of select="$goals"/></td>
            </tr>
            <tr>
                <td class="l">
                    <xsl:if test="count(goals/goal[@team=1]) > 0">
                        <xsl:for-each select="goals/goal[@team=1]">
                            <xsl:value-of select="@minute"/><xsl:text>. </xsl:text><xsl:value-of select="@player"/>
                            <br/>
                        </xsl:for-each>
                    </xsl:if>                    
                </td>
                <td>&#160;</td>
                <td class="r">
                    <xsl:if test="count(goals/goal[@team=2]) > 0">
                        <xsl:for-each select="goals/goal[@team=2]">
                            <xsl:value-of select="@minute"/><xsl:text>. </xsl:text><xsl:value-of select="@player"/>
                            <br/>
                        </xsl:for-each>
                    </xsl:if>
                </td>
            </tr>
            <tr>
                <td class="l h2"><xsl:value-of select="$cards"/></td>
                <td>&#160;</td>
                <td class="r h2"><xsl:value-of select="$cards"/></td>
            </tr>            
            <tr>
                <td class="l">
                    <xsl:if test="count(cards/card[@team=1]) > 0">
                        <xsl:for-each select="cards/card[@team=1]">
                            <xsl:value-of select="@minute"/><xsl:text>. </xsl:text><xsl:value-of select="@player"/><xsl:text> (</xsl:text><xsl:value-of select="@type"/><xsl:text>)</xsl:text>
                            <br/>
                        </xsl:for-each>
                    </xsl:if>                    
                </td>
                <td>&#160;</td>
                <td class="r">
                    <xsl:if test="count(cards/card[@team=2]) > 0">
                        <xsl:for-each select="cards/card[@team=2]">
                            <xsl:value-of select="@minute"/><xsl:text>. </xsl:text><xsl:value-of select="@player"/><xsl:text> (</xsl:text><xsl:value-of select="@type"/><xsl:text>)</xsl:text>
                            <br/>
                        </xsl:for-each>
                    </xsl:if>
                </td>
            </tr>
            <tr>
                <td class="l h2"><xsl:value-of select="$changes"/></td>
                <td>&#160;</td>
                <td class="r h2"><xsl:value-of select="$changes"/></td>
            </tr>             
            <tr>
                <td class="l">
                    <xsl:if test="count(changes/change[@team=1]) > 0">
                        <xsl:for-each select="changes/change[@team=1]">
                            <xsl:value-of select="@minute" /><xsl:text>. </xsl:text><xsl:value-of select="@out"/><xsl:text> => </xsl:text><xsl:value-of select="@in" />
                            <br/>
                        </xsl:for-each>
                    </xsl:if>                    
                </td>
                <td>&#160;</td>
                <td class="r">
                    <xsl:if test="count(changes/change[@team=2]) > 0">
                        <xsl:for-each select="changes/change[@team=2]">
                            <xsl:value-of select="@minute"/><xsl:text>. </xsl:text><xsl:value-of select="@out"/><xsl:text> => </xsl:text><xsl:value-of select="@in"/>
                            <br/>
                        </xsl:for-each>
                    </xsl:if>
                </td>
            </tr>
            <tr>
                <td class="l h2"><xsl:value-of select="$players"/></td>
                <td>&#160;</td>
                <td class="r h2"><xsl:value-of select="$players"/></td>
            </tr>             
            <tr>
                <td class="l">
                    <xsl:if test="count(home-team/player) > 0">
                        <xsl:for-each select="home-team/player">
                            <xsl:value-of select="@name"/>
                            <br/>
                        </xsl:for-each>
                    </xsl:if>                    
                </td>
                <td>&#160;</td>
                <td class="r">
                    <xsl:if test="count(guest-team/player) > 0">
                        <xsl:for-each select="guest-team/player">
                            <xsl:value-of select="@name"/>
                            <br/>
                        </xsl:for-each>
                    </xsl:if>
                </td>
            </tr>
        </table>
    </xsl:template>
</xsl:stylesheet>
